Skip to content

[fix](test) stabilize CreateResourceCommandTest#65767

Draft
shuke987 wants to merge 1 commit into
apache:branch-4.1from
shuke987:codex/fix-branch41-create-resource-command-test
Draft

[fix](test) stabilize CreateResourceCommandTest#65767
shuke987 wants to merge 1 commit into
apache:branch-4.1from
shuke987:codex/fix-branch41-create-resource-command-test

Conversation

@shuke987

@shuke987 shuke987 commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: DORIS-26901

Related PR: #65072, #62221

Problem Summary:

CreateResourceCommandTest starts a real FE, but testValidate globally mocks Env with JMockit. FE background daemons concurrently call Env.getServingEnv().isReady() while the test records expectations. JMockit's process-wide record state is then contaminated, causing intermittent MissingInvocation, incompatible return type, and ConcurrentModificationException failures before the resource validation assertions run.

The failure appeared in 11 of 80 branch-4.1 FE UT occurrences across 7 unrelated PRs. #65072 retained/widened the global JMockit setup on branch-4.1, while #62221 already uses the narrow Mockito pattern on master.

This PR keeps the real FE Env, spies only AccessControllerManager, stubs the single ADMIN privilege decision needed by the test, and injects the spy into the real environment. It removes the global JMockit mocks for Env, AccessControllerManager, and SystemInfoService.

No production code or resource validation assertion is changed.

Validation:

  • ./run-fe-ut.sh --run org.apache.doris.nereids.trees.plans.commands.CreateResourceCommandTest
  • mvn test -Dcheckstyle.skip=true -DfailIfNoTests=false -Dtest=org.apache.doris.nereids.trees.plans.commands.CreateResourceCommandTest
  • Exact class passed in both rounds: 2 tests, 0 failures, 0 errors per round.
  • Full Maven reactor succeeded in both rounds.
  • git diff --check passed.

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@shuke987

Copy link
Copy Markdown
Collaborator Author

run buildall

@shuke987

Copy link
Copy Markdown
Collaborator Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review summary

Overall: No blocking issue found. This test-only change removes the process-wide JMockit mocks, keeps the real FE Env, and limits the test double to the single ADMIN decision exercised by testValidate; production resource behavior is unchanged.

Critical checkpoints:

  • Correctness and test intent: the Mockito matchers bind to the exact checkGlobalPriv(ConnectContext, ADMIN) call used by CreateResourceInfo.validate(), so the normal and invalid-property/type assertions still reach their intended validation paths.
  • Lifecycle and concurrency: the injected spy remains for the rest of this test class, but FE UT classes run in non-reused Surefire forks, the only later method uses the root context whose real manager also grants ADMIN, and the spy delegates all other calls. No observable same-class, cross-class, or daemon-race defect was substantiated.
  • Compatibility, security, and performance: only test code changes; no production API, persistence, authorization, runtime, or resource-type behavior changes.
  • Test coverage and validation: the full one-file diff and both test paths were reviewed statically. Per the PR description, the exact FE test class and full Maven reactor passed twice; this review runner did not rerun builds or tests.
  • Documentation and release notes: no documentation or release note is needed for this test stabilization.

User focus: No additional user-provided focus was supplied; the full PR was reviewed.

Conclusion: comment-only approval opinion with no inline issues.

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage `` 🎉
Increment coverage report
Complete coverage report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants